@extends('default.layouts.adminPublic')
@section('title', '员工管理列表')
@section('content')
<!--导航开始-->
<div class="crumb_warp">
    <i class="fa fa-home"></i> <a href="{{url('admin')}}">首页</a> &raquo; 客服销售员工管理
</div>
<!--导航结束-->

<!--搜索结果页面 列表开始-->

    <div class="result_wrap">
        <div class="result_title">
            <div class="search">
                <form action="{{url('admin/workerhandle')}}" method="get">
                    <span>关键字：</span>
                    <span><input name="keyword" value="{{$keyword or ''}}" placeholder="请输入员工UID/名称/帐号/手机号/座机号" type="text"></span>
                    <span><input name="submit" class="skeyword" value="搜索" type="submit"></span>
                </form>
            </div>
        </div>
        <!--快捷导航 开始-->
        <div class="result_content">
            <div class="short_wrap">
                <a href="{{url('admin/workerhandle/create')}}"><i class="fa fa-plus"></i>添加员工</a>
                <a href="{{url('admin/workerhandle')}}"><i class="fa fa-recycle"></i>员工列表</a>
            </div>
        </div>
        <!--快捷导航 结束-->
    </div>

    <div class="result_wrap">
        <div class="result_content">
            <table class="list_tab">
                <tr>
                    <th width="20%">UID/员工名称/员工帐号</th>
                    <th width="30%">员工手机号/座机号</th>
                    <th>所属角色</th>
                    <th width="15%">操作</th>
                </tr>
                @if(count($userList) > 0)
                    @foreach($userList as $v)
                        <tr>
                            <td>{{ $v->uid.' / '.$v->worker_name.'【'.$v->name.'】' }}</td>
                            <td>{{ $v->mobile . ' / ' . $v->phone}}</td>
                            <td>
                                <strong style="font-size: 15px; color: #777; margin-right:15px;">{{ !empty($display_name[$v->uid]) ? $display_name[$v->uid] : '未分配' }}</strong>
                            </td>
                            <td>
                                <a href="{{ url("admin/workerhandle/".$v->uid."/edit/") }}">修改</a>
                                <a onclick="delWorker(this,'{{ $v->uid }}','{{ $v->name }}')">删除</a>
                            </td>
                        </tr>
                    @endforeach
                @else
                    <tr>
                        <td colspan="4" style="text-align: center;">暂无数据</td>
                    </tr>
                @endif
            </table>
            <div class="page_list" style="width: 100%">
               {!! $userList->links() !!}
            </div>

        </div>
    </div>
<script type="text/javascript" src="{{asset('/default/js/jquery.js')}}"></script>
<script type="text/javascript" src="{{asset('/vendor/org/layer/layer.js')}}"></script>
<script>
    function delWorker(othis,id,name) {
        layer.confirm('您确定要删除['+name+']员工吗？', {
            btn: ['确定', '取消'] //按钮
        }, function (index) {
            $.post("{{ url('admin/workerhandle') }}/" + id, {
                '_method': 'delete',
                '_token': "{{csrf_token()}}",
                'name': name
            }, function (data) {
                if (data.status == 0) {
                    location.href="{{ url("admin/workerhandle") }}";
                } else {
                    layer.msg(data.msg,{icon: 5})
                }
            });
            layer.close(index);
        });
    }
    Tip ={!! !empty(session("ok")) ? session("ok") : "''" !!};
    if(Tip.status != undefined){
        switch (Tip.status){
            case 0:
                layer.msg(Tip.msg, {icon: 6});
                break;
            case 1:
                layer.msg(Tip.msg, {icon: 5});
                break;
        }
    }
</script>
@endsection